package com.lms.dao;

import com.lms.bean.Book;
import com.lms.bean.Type;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BookDao extends JpaRepository<Book, Long>, JpaSpecificationExecutor<Book> {
    @Query("select b from Book b")
    List<Book> getList(Pageable pageable);

    @Query("select b from Book b where b.bookName like ?1")
    List<Book> findByBookName(String s, Pageable pageable);

    @Query("select count(b) from Book b where b.bookName like ?1")
    Long countByBookName(String s);

    List<Book> findAllByTypeTypeId(Long type_typeId);

/*    @Query("select b.bookId from Book b where b.bookName like?1")
    List<Long> findBookIdByName(String bookname);*/
}
